﻿/****** Object:  Table [RoleMaster]    Script Date: 09/11/2014 01:28:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[RoleMaster]') AND type in (N'U'))
DROP TABLE [RoleMaster]
GO
/****** Object:  Table [RoleMaster]    Script Date: 03/02/2011 17:15:08 ******/
PRINT 'CREATING TABLE .... [RoleMaster]'
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[RoleMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [RoleMaster](
	[RoleKey] [int] IDENTITY(1,1) NOT NULL,
	[RoleCode] [varchar](20) NOT NULL,
	[RoleName] [varchar](50) NOT NULL,
	[RoleDescription] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_RoleMaster] PRIMARY KEY CLUSTERED 
(
	[RoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleCode] UNIQUE NONCLUSTERED 
(
	[RoleCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleName] UNIQUE NONCLUSTERED 
(
	[RoleName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'RoleMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'RoleMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'RoleMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'RoleMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'RoleMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO